﻿@using GoodMan.Infrastructure.Entities.Entity;
@{
    ViewBag.Title = "线下销售";
    Layout = "~/Areas/WorkSpace/Views/Shared/_StaffTemplete.cshtml";
    Product data = ViewBag.Data;

    string productCode = ViewBag.ProductCode;
}
@section head{
    <script type="text/javascript">
        var r = /-?\d*\.?\d*/;
        function changecount(price) {

            var obj = $("input[name='salsecount']");
            var value = obj.val();

            if (!r.test(value * 1)) {
                $("input[name='salsecount']").val("");
                value = 0;
            }
            if (value == "-") {
                value = 0;

            }

            var remain = $("input[name='remain']").val();
            if ((remain * 1) < (value * 1)) {
                alert("不能大于库存量。");
                $("input[name='salsecount']").val("");
                $("span[id='totalmoney']").html("0.00");
            }
            else {
                var totalMoney = price * value;

                $("span[id='totalmoney']").html(fffmoney(totalMoney, 2));
            }
        }



        function fffmoney(s, n) {
            n = n > 0 && n <= 20 ? n : 2;
            s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
            var l = s.split(".")[0].split("").reverse();
            var r = s.split(".")[1];
            var t = "";
            for (i = 0; i < l.length; i++) {
                t += l[i] + "";
            }
            return t.split("").reverse().join("") + "." + r;

        }
        
    </script>
}
<div id="content-header">
    <h1>
        线下销售</h1>
</div>
<div id="breadcrumb">
    <a href="index.html" title="Go to Home" class="tip-bottom"><i class="icon-home"></i>
        首页</a> <a href="#" class="tip-bottom">订单管理</a> <a href="#" class="current">线下销售</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
                    <span class="icon"><i class="icon-th"></i></span>
                    <h5>
                        线下销售</h5>
                </div>
                <div class="widget-content nopadding">
                    <table border="0" cellpadding="0" cellspacing="0">
                        <form action="/WorkSpace/Staff/OutLineSales" method="post" id="productDetailForm"
                        class="form-horizontal">
                        <tr>
                            <td align="right">
                                <div class="control-group">
                                    <div class="controls" style="text-align:center; margin-top:10px; margin-left:40px;">
                                        货号：<input type="text" value="@productCode" name="productCode"
                                         style="width: 40%" />
                                    </div>
                                </div>
                            </td>
                            <td style="width: 20%">
                                <div class="control-group">
                                    <div class="controls">
                                        <button type="submit" class="btn btn-primary">
                                            <i class="icon-search icon-white"></i>查询</button>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        </form>
                        <tr>
                            <td colspan="3">
                                <form action="/WorkSpace/Staff/OutLineBuy" method="post" id="OutLineBuy" class="form-horizontal">
                                <table class="table table-bordered table-striped">
                                    <thead>
                                        <tr>
                                            <th width="25%">
                                                货号
                                            </th>
                                            <th width="35%">
                                                名称
                                            </th>
                                            <th width="10%">
                                                默认售价
                                            </th>
                                            <th width="10%">
                                                现售价格
                                            </th>
                                            <th width="10%">
                                                库存数量
                                            </th>
                                            <th width="10%">
                                                数量
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @{
                                            if (data != null)
                                            {
                                            <tr>
                                                <td style="vertical-align: middle">
                                                    @data.ProductCode
                                                    <input type="hidden" name="productId" value="@data.Id" />
                                                    <input type="hidden" name="code" value="@data.ProductCode" />
                                                </td>
                                                <td style="vertical-align: middle">
                                                    <a href="../../Shop/ProductItemView?Id=@data.Id" target="_blank" ><span title="@data.ProductName">@data.ProductName</span></a>
                                                </td>
                                                <td style="vertical-align: middle">@data.DefaulSalePrice
                                                </td>
                                                <td style="vertical-align: middle">@data.PolicyPrice
                                                </td>
                                                <td style="vertical-align: middle">@data.TotalRemain
                                                    <input type="hidden" name="remain" value="@data.TotalRemain" />
                                                </td>
                                                <td class="center">
                                                    <input type="text" name="salsecount"  value="" onkeyup="changecount(@data.PolicyPrice)" style="width: 50px" onkeypress="if (event.keyCode!=46 && event.keyCode!=45 && (event.keyCode<48 || event.keyCode>57)) event.returnValue=false"/>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="right" style="text-align: right;" colspan="5">
                                                    总金额:
                                                </td>
                                                <td style="text-align: center; color: #DC143C;">
                                                    &yen;<span id="totalmoney" name="totalmoney">0.00</span>
                                                </td>
                                            </tr>
                                            } 
                                        }
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="form-actions" style="text-align: right;">
                    <button type="submit" class="btn btn-primary">
                        结算</button>
                </div>
                </form>
                @{
                                         
                    if (ViewBag.Message != null)
                    {
                        if (ViewBag.Message)
                        { 
                    <div class="alert alert-success">
                        <strong>@ViewBag.MessageStr</strong>
                    </div>
                                                 
                        }
                        else
                        {
                    <div class="alert alert-error">
                        <strong>@ViewBag.MessageStr</strong>
                    </div>
                                                 
                        }
                    }
                }
                
            </div>
        </div>
    </div>
</div>
@section tail{
<script type="text/javascript">
    $(function () {
        $('#likOrder').addClass('open');
        $('#likOrder').addClass('active');
    });
</script>
